package cn.com.dstz.data.post;

import org.apache.commons.lang.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;


/**
 * 公告POST数据格式，接收两个参数
 * topaid, content
 * @author 叶装装
 *
 */
public class NoticeKeyVal extends PostKeyVal{
	
	private Object topaid;	//	居间ID
	private String content;	//  内容
	
	/**
	 * 务必要调用super()
	 * @param topaid
	 * @param content
	 */
	public NoticeKeyVal( Object topaid, String content ){
		super( );
		this.topaid = topaid;
		this.content = deleteWhiteSpace( content ); // 去除空格，并且只发送100个字符
	}
	
	/**
	 * 公告发布格式：
	 * gonggao~!^$" +admin.get( "topaid" ) +"~!^$" + content.replaceAll(" ", "")
	 */
	@Override
	public String processValue( ) {
		StringBuffer buffer = new StringBuffer( );
		
		appendToBufferWithDefaultSep(buffer, "gonggao", true );
		appendToBufferWithDefaultSep(buffer, topaid, true );
		if( StringUtils.isNotBlank( content ) ){
			content = Jsoup.clean( content, Whitelist.none( ) ); // 去除所有的标签
			if( content.length( ) > 100 ){
				content = content.substring( 0, 100 );
			}
		}
		appendToBufferWithDefaultSep(buffer, content, false );
		
		return buffer.toString( );
	}
	
	public Object getTopaid( ) {
		return topaid;
	}
	
	public void setTopaid( Object topaid ) {
		this.topaid = topaid;
	}
	
	public String getContent( ) {
		return content;
	}
	
	public void setContent( String content ) {
		this.content = content;
	}
	
	

}
